import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import game.Game;
import game.GameDriver;
import game.Round;
import game.Timers;

import java.awt.Color;

import org.junit.Before;
import org.junit.Test;

import panels.MapPanel;
import player.Alien;
import player.Flapper;
import player.Human;
import player.Player;
import tiles.Tile;
import town.Store;

public class YasasviTest {
    GameDriver driver;
    Game game;
    Round round;

    Player p1;
    Player p2;
    Player p3;
    Player p4;

    Store store;

    @Before
    public void setUp() {
	driver = new GameDriver();
	game = new Game(4, 1, 1);

	p1 = new Player(game, "bob", Color.RED, "red", new Flapper());
	p2 = new Player(game, "sally", Color.CYAN, "cyan", new Human());
	p3 = new Player(game, "dave", Color.GREEN, "green", new Human());
	p4 = new Player(game, "phil", Color.YELLOW, "yellow", new Alien());

	game.setPlayer(p1, 0);
	game.setPlayer(p2, 1);
	game.setPlayer(p3, 2);
	game.setPlayer(p4, 3);

	round = new Round(game, driver);
	store = new Store(game, driver, round);

    }

//    @Test
//    public void testMuleEmplace() {
//	MapPanel map = new MapPanel(game, driver, round);
//
//	// adding food mule
//
//	Tile tileToAdd = map.getMap()[2][2];
//	round.incrementPlayerInt();
//	round.incrementPlayerInt();
//	p3.addProperty(tileToAdd);
//	p3.buyMule(0);
//	round.getCurrPlayer().placeMule(tileToAdd);
//	assertTrue(tileToAdd.hasMule());
//
//	// adding energy mule
//
//	Tile tileToAdd2 = map.getMap()[3][1];
//	p3.addProperty(tileToAdd2);
//	p3.buyMule(1);
//	round.getCurrPlayer().placeMule(tileToAdd2);
//	assertTrue(tileToAdd2.hasMule());
//
//	// adding crystite mule
//
//	Tile tileToAdd3 = map.getMap()[4][1];
//	p3.addProperty(tileToAdd3);
//	p3.buyMule(2);
//	round.getCurrPlayer().placeMule(tileToAdd3);
//	assertTrue(tileToAdd3.hasMule());
//
//	// adding mule to wrong tile
//
//	Tile tileToAdd4 = map.getMap()[2][4];
//	Tile wrongTile = map.getMap()[4][4];
//	p3.addProperty(tileToAdd4);
//	p3.buyMule(0);
//	round.getCurrPlayer().placeMule(wrongTile);
//	assertFalse(wrongTile.hasMule());
//	assertFalse(p3.hasMule());
//
//	// adding mule to tile that already has mule
//
//	p3.buyMule(0);
//	round.getCurrPlayer().placeMule(tileToAdd);
//	assertTrue(p3.hasMule());
//	assertTrue(tileToAdd.hasMule());
//
//	// adding mule to other player's tile
//
//	Tile tileToAdd5 = map.getMap()[2][3];
//	p4.addProperty(tileToAdd5);
//	p3.buyMule(0);
//	p3.placeMule(tileToAdd5);
//	assertFalse(p3.hasMule());
//	assertFalse(tileToAdd5.hasMule());
//    }
    
    @Test
    public void testSecondsLeft(){
	MapPanel map = new MapPanel(game, driver, round);
	int foodReq = round.getFoodRequirement();
	int playerFood = round.getCurrPlayerResource(0);
	assertEquals(3, foodReq);
	assertEquals(8, playerFood);

	System.out.println("Starting Food Requirement: " + foodReq);
	System.out.println("Starting Player Food: " + playerFood);
	
	Timers t = new Timers(foodReq, playerFood, round, game, driver);
	int startTime = t.setSecondsLeft(playerFood, foodReq);
	System.out.println("Start Time: "+ startTime);
	
	assertEquals(startTime, 50);
	
	p1.sellResource(0, 8, 25);
	playerFood = round.getCurrPlayerResource(0);
	assertEquals(0, playerFood);

	round.incrementCount();	
	round.incrementCount();
	round.incrementCount();
	round.incrementCount();
	round.incrementCount();
	
	foodReq = round.getFoodRequirement();
	System.out.println("Current Food Requirement: " + foodReq);
	
	t = new Timers(foodReq, playerFood, round, game, driver);
	startTime = t.setSecondsLeft(playerFood, foodReq);
	assertEquals(startTime, 5);


	
    }
}